home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume17 / parseargs / patch03 < prev    next >
Encoding:
Internet Message Format  |  1991-03-30  |  39.2 KB

  1. From: brad@hcx1.ssd.csd.harris.com (Brad Appleton)
  2. Newsgroups: comp.sources.misc
  3. Subject: v17i075:  parseargs - functions to parse command line arguments, Patch03
  4. Message-ID: <1991Mar29.192517.5209@sparky.IMD.Sterling.COM>
  5. Date: 29 Mar 91 19:25:17 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 00fcdb2d decc6041 be60ca5f 585ee4a4
  8.  
  9. Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  10. Posting-number: Volume 17, Issue 75
  11. Archive-name: parseargs/patch03
  12. Patch-To: parseargs: Volume 17, Issue 45-57
  13.  
  14. This is a patch for the ascii version of the parseargs documentation.
  15.  
  16. It corresponds to the previous patch (patch2) that I sent.
  17.  
  18. ______________________ "And miles to go before I sleep." ______________________
  19.  Brad Appleton                         Harris Corp., Computer Systems Division
  20.    Software Engineer                   2101 West Cypress Creek Road,  M/S 161 
  21.      brad@ssd.csd.harris.com           Fort Lauderdale, FL  33309-1892  USA
  22.        ...!uunet!hcx1!brad                 Phone: (305) 973-5360
  23. ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~
  24. #! /bin/sh
  25. # This is a shell archive.  Remove anything before this line, then unpack
  26. # it by saving it into a file and typing "sh file".  To overwrite existing
  27. # files, type "sh file -c".  You can also feed this as standard input via
  28. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  29. # will see the following message at the end:
  30. #        "End of shell archive."
  31. # Contents:  PATCH
  32. # Wrapped by brad@hcx2 on Tue Mar 26 12:05:39 1991
  33. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  34. if test -f 'PATCH' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'PATCH'\"
  36. else
  37. echo shar: Extracting \"'PATCH'\" \(36746 characters\)
  38. sed "s/^X//" >'PATCH' <<'END_OF_FILE'
  39. X*** argtype3.txt.OLD    Tue Mar 26 12:01:39 1991
  40. X--- argtype3.txt    Tue Mar 26 11:59:44 1991
  41. X***************
  42. X*** 38,54 ****
  43. X  DESCRIPTION
  44. X       Each of these converts a parameter    value to the internal
  45. X       form, including validity checking.     Their parameters and
  46. X!      return values all behave similarly. One of    these routines
  47. X!      are called    when an    argunent of that particular type is
  48. X!      matched by    one of the argument parsing function in    par-
  49. X!      seargs(3).    When such an argument is matched, its argument
  50. X!      translation routines is invoked and is passed (1) the
  51. X!      address of    the argument descriptor    for the    matched    argument,
  52. X!      (2) the possible argument string for that matched argument,
  53. X!      and (3) a boolean filed that is TRUE only if the second
  54. X!      parameter points to temporary storage (indicating that some
  55. X!      copying may need to be done instead of just pointing to the
  56. X!      same object).
  57. X  
  58. X       Once the argument translation routine is invoked, it is
  59. X       responsible for converting    the argument string to the
  60. X--- 38,54 ----
  61. X  DESCRIPTION
  62. X       Each of these converts a parameter    value to the internal
  63. X       form, including validity checking.     Their parameters and
  64. X!      return values all behave similarly. One of    these routines is
  65. X!      called when an argument of    that particular    type is    matched
  66. X!      by    one of the argument parsing function in    parseargs(3).
  67. X!      When such an argument is matched, its argument translation
  68. X!      routines is invoked and is    passed (1) the address of the
  69. X!      argument descriptor for the matched argument, (2) the possi-
  70. X!      ble argument string for that matched argument, and    (3) a
  71. X!      boolean filed that    is TRUE    only if    the second parameter
  72. X!      points to temporary storage (indicating that some copying
  73. X!      may need to be done instead of just pointing to the same
  74. X!      object).
  75. X  
  76. X       Once the argument translation routine is invoked, it is
  77. X       responsible for converting    the argument string to the
  78. X***************
  79. X*** 91,103 ****
  80. X           still match other arguments.
  81. X  
  82. X  
  83. X! PSEUDO-TYPES
  84. X       ArgUsage is used to specify an argument that causes the com-
  85. X       mand usage    to be printed.
  86. X  
  87. X       ArgDummy is used to force an item to show up in usage-
  88. X       messages but the item itself is never matched against any
  89. X!      argumenmts    from the command-line.
  90. X  
  91. X       ArgEnd is used by Amiga style command-lines to indicate an
  92. X       argument that forces all remaining    arguments to be    con-
  93. X--- 91,103 ----
  94. X           still match other arguments.
  95. X  
  96. X  
  97. X! PSEUDO-TYPES: argUsage,    argDummy, argEnd
  98. X       ArgUsage is used to specify an argument that causes the com-
  99. X       mand usage    to be printed.
  100. X  
  101. X       ArgDummy is used to force an item to show up in usage-
  102. X       messages but the item itself is never matched against any
  103. X!      arguments from the    command-line.
  104. X  
  105. X       ArgEnd is used by Amiga style command-lines to indicate an
  106. X       argument that forces all remaining    arguments to be    con-
  107. X***************
  108. X*** 108,114 ****
  109. X       available for identification in the corresponding command-
  110. X       line styles.
  111. X  
  112. X! STRING-TYPES
  113. X       ArgStr is one of the few argument translation routines that
  114. X       actually uses the copyf flag. If copyf is true then the
  115. X       string is duplicated.
  116. X--- 108,114 ----
  117. X       available for identification in the corresponding command-
  118. X       line styles.
  119. X  
  120. X! STRING-TYPES: argStr
  121. X       ArgStr is one of the few argument translation routines that
  122. X       actually uses the copyf flag. If copyf is true then the
  123. X       string is duplicated.
  124. X***************
  125. X*** 137,143 ****
  126. X  
  127. X  
  128. X  
  129. X! CHARACTER-TYPES
  130. X       ArgChar assigns the given character to the    value referenced
  131. X       by    arg_valp(ad) (unless the argument is a vector in which
  132. X       case the given character is appended to the end).
  133. X--- 137,143 ----
  134. X  
  135. X  
  136. X  
  137. X! CHARACTER-TYPES: argChar
  138. X       ArgChar assigns the given character to the    value referenced
  139. X       by    arg_valp(ad) (unless the argument is a vector in which
  140. X       case the given character is appended to the end).
  141. X***************
  142. X*** 150,156 ****
  143. X       Unlike argStr, argChar will translate character escape
  144. X       sequences such as `\n' and    `\012'.
  145. X  
  146. X! INTEGER-TYPES
  147. X       Each of these functions converts the given    string to the
  148. X       desired integral type. The    value may be specified as an
  149. X       octal number by specifying    the first digit    to be 0. Simi-
  150. X--- 150,156 ----
  151. X       Unlike argStr, argChar will translate character escape
  152. X       sequences such as `\n' and    `\012'.
  153. X  
  154. X! INTEGER-TYPES: argInt, argShort, argLong
  155. X       Each of these functions converts the given    string to the
  156. X       desired integral type. The    value may be specified as an
  157. X       octal number by specifying    the first digit    to be 0. Simi-
  158. X***************
  159. X*** 157,167 ****
  160. X       larly, If the first two characters    are `0x' then the number
  161. X       is    treated    as hexadecimal.
  162. X  
  163. X! FLOATING-POINT-TYPES
  164. X       Each of these functions converts the given    string to the
  165. X       desired floating-point type.
  166. X  
  167. X! BOOLEAN-TYPES
  168. X       ArgBool and argSBool set a    boolean    value (if no value is
  169. X       given).  ArgUBool unsets a    boolean    value (if no value is
  170. X       given). ArgTBool toggles a    boolean    value (if no value is
  171. X--- 157,167 ----
  172. X       larly, If the first two characters    are `0x' then the number
  173. X       is    treated    as hexadecimal.
  174. X  
  175. X! FLOATING-POINT-TYPES: argFloat,    argDouble
  176. X       Each of these functions converts the given    string to the
  177. X       desired floating-point type.
  178. X  
  179. X! BOOLEAN-TYPES: argBool,    argSBool, argTBool, argUBool
  180. X       ArgBool and argSBool set a    boolean    value (if no value is
  181. X       given).  ArgUBool unsets a    boolean    value (if no value is
  182. X       given). ArgTBool toggles a    boolean    value (if no value is
  183. X***************
  184. X*** 209,215 ****
  185. X       ``1'', ``+'', ``ON'', or ``TRUE''
  186. X        The corresponding boolean flag is set    to TRUE.
  187. X  
  188. X! LIST TYPES
  189. X       The listStr argument translation routine is only intended
  190. X       for use on    behalf of arguments that have the ARGLIST flag
  191. X       enabled. It will allocate space for a new node (and for the
  192. X--- 209,215 ----
  193. X       ``1'', ``+'', ``ON'', or ``TRUE''
  194. X        The corresponding boolean flag is set    to TRUE.
  195. X  
  196. X! LIST TYPES: listStr
  197. X       The listStr argument translation routine is only intended
  198. X       for use on    behalf of arguments that have the ARGLIST flag
  199. X       enabled. It will allocate space for a new node (and for the
  200. X***************
  201. X*** 229,235 ****
  202. X       followed by the type of the items in the vector.
  203. X  
  204. X  SEE ALSO
  205. X!      parseargs(3), parseargs(1),
  206. X  
  207. X  
  208. X  
  209. X--- 229,235 ----
  210. X       followed by the type of the items in the vector.
  211. X  
  212. X  SEE ALSO
  213. X!      parseargs(3), parseargs(3), parsecntl(1),
  214. X  
  215. X  
  216. X  
  217. X*** parseargs1.txt.OLD    Tue Mar 26 12:01:48 1991
  218. X--- parseargs1.txt    Tue Mar 26 11:59:52 1991
  219. X***************
  220. X*** 81,87 ****
  221. X       the desired type, and diagnoses problems such as missing
  222. X       arguments,    extra arguments, and argument values that are
  223. X       syntactically incorrect.  Other behavior such as prompting
  224. X!      the user for missing arguments and    ignoring as command-line
  225. X       syntax may    be specified on    the command-line through the use
  226. X       of    various    options, or through the    use of the ``PARSECNTL''
  227. X       environment variable.
  228. X--- 81,87 ----
  229. X       the desired type, and diagnoses problems such as missing
  230. X       arguments,    extra arguments, and argument values that are
  231. X       syntactically incorrect.  Other behavior such as prompting
  232. X!      the user for missing arguments and    ignoring bad command-line
  233. X       syntax may    be specified on    the command-line through the use
  234. X       of    various    options, or through the    use of the ``PARSECNTL''
  235. X       environment variable.
  236. X***************
  237. X*** 233,243 ****
  238. X       ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'',
  239. X       ``awk'', and ``perl'' as valid command interpreters. Awk
  240. X       output is slightly    different from that of the other shells
  241. X!      in    that the actual    variable setting are not printed but each
  242. X!      line of an    associative array is printed (the first    field is
  243. X!      the array index, the second is the    value for that index).
  244. X!      If    no shell is specified, then the    Bourne shell (``sh'')
  245. X!      will be assumed.
  246. X  
  247. X       If    the user wishes    to use a value other than ``TRUE'' for a
  248. X       boolean flag that is true,    this may be done using the -T
  249. X--- 233,243 ----
  250. X       ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'',
  251. X       ``awk'', and ``perl'' as valid command interpreters. Awk
  252. X       output is slightly    different from that of the other shells
  253. X!      in    that the actual    variable settings are not printed but
  254. X!      each line of an associative array is printed (the first
  255. X!      field is the array    index, the second is the value for that
  256. X!      index).  If no shell is specified,    then the Bourne    shell
  257. X!      (``sh'') will be assumed.
  258. X  
  259. X       If    the user wishes    to use a value other than ``TRUE'' for a
  260. X       boolean flag that is true,    this may be done using the -T
  261. X***************
  262. X*** 274,280 ****
  263. X       parseargs to be able to distinguish options to itself from
  264. X       options for the calling program.
  265. X  
  266. X!      The default behavior of parseargs is allow    both single-
  267. X       character options and long-options    (keywords) on the
  268. X       command-line. The user may    specify    that only options (long-
  269. X       options) are to be    permitted by specifying    the -o (-l)
  270. X--- 274,280 ----
  271. X       parseargs to be able to distinguish options to itself from
  272. X       options for the calling program.
  273. X  
  274. X!      The default behavior of parseargs is to allow both    single-
  275. X       character options and long-options    (keywords) on the
  276. X       command-line. The user may    specify    that only options (long-
  277. X       options) are to be    permitted by specifying    the -o (-l)
  278. X***************
  279. X*** 340,349 ****
  280. X       positional    parameters of the calling program will be re-
  281. X       assigned to the contents of the argument list.
  282. X  
  283. X!      For the awk and perl, if the variable name    corresponding to
  284. X!      the ARGLIST argument is ``ARGV'', then the    positional
  285. X!      parameters    of the calling program will be re-assigned to the
  286. X!      contents of the argument list.
  287. X       Bourne Shell Argument Lists
  288. X  
  289. X       For the Bourne shell, if the associated variable name is NOT
  290. X--- 340,349 ----
  291. X       positional    parameters of the calling program will be re-
  292. X       assigned to the contents of the argument list.
  293. X  
  294. X!      For awk and perl, if the variable name corresponding to the
  295. X!      ARGLIST argument is ``ARGV'', then    the positional parameters
  296. X!      of    the calling program will be re-assigned    to the contents
  297. X!      of    the argument list.
  298. X       Bourne Shell Argument Lists
  299. X  
  300. X       For the Bourne shell, if the associated variable name is NOT
  301. X***************
  302. X*** 471,479 ****
  303. X  
  304. X       For perl, each argument list is considered    an array and is
  305. X       set using the following syntax:
  306. X!       @name=( arg1 , arg2 ,     ... )
  307. X  
  308. X- 
  309. X       The word-lists used by the    C shell, the arrays used by the
  310. X       Korn shell, the Plan 9 shell, awk,    perl, and the positional
  311. X       parameters    used by    all shells (if overwritten by parseargs)
  312. X--- 471,479 ----
  313. X  
  314. X       For perl, each argument list is considered    an array and is
  315. X       set using the following syntax:
  316. X!       @name=( arg1 , arg2 ,     ... );
  317. X!      A Final Note on Argument Lists
  318. X  
  319. X       The word-lists used by the    C shell, the arrays used by the
  320. X       Korn shell, the Plan 9 shell, awk,    perl, and the positional
  321. X       parameters    used by    all shells (if overwritten by parseargs)
  322. X***************
  323. X*** 493,499 ****
  324. X       is    parsed.     The command-line will over-ride any options that
  325. X       are specified in this environment variable    (except    that
  326. X       ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
  327. X!      from the command-line
  328. X  
  329. X       It    is important to    note that the contents of the
  330. X       ``CMD_ARGS'' environment variable are NOT expanded    by the
  331. X--- 493,499 ----
  332. X       is    parsed.     The command-line will over-ride any options that
  333. X       are specified in this environment variable    (except    that
  334. X       ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
  335. X!      from the command-line if they are selected).
  336. X  
  337. X       It    is important to    note that the contents of the
  338. X       ``CMD_ARGS'' environment variable are NOT expanded    by the
  339. X***************
  340. X*** 552,558 ****
  341. X        Ignore any unrecognized or improperly    specified
  342. X        command-line arguments and continue execution    of the
  343. X        program. Normally, if    an argument is unmatched (or is
  344. X!       improperly specified), a usage message is printed
  345. X        program execution is terminated.
  346. X  
  347. X       OptsOnly
  348. X--- 552,558 ----
  349. X        Ignore any unrecognized or improperly    specified
  350. X        command-line arguments and continue execution    of the
  351. X        program. Normally, if    an argument is unmatched (or is
  352. X!       improperly specified), a usage message is printed and
  353. X        program execution is terminated.
  354. X  
  355. X       OptsOnly
  356. X***************
  357. X*** 599,612 ****
  358. X  
  359. X  
  360. X  
  361. X!       Setting this flag cause character-case to be ignored
  362. X        when attempting to match single-character argument
  363. X        names    (i.e. causes "-i" and "-I" will    be considered
  364. X        equivalent).
  365. X  
  366. X       If    the environment    variable ``PARSECNTL'' is empty    or
  367. X!      undefined,    then parsing behavior set by the programmer is
  368. X!      used.  If the programmer has not explicitly used
  369. X       parsecntl(3) to modify the    parsing    behavior, then the
  370. X       default behavior will be ``Flags1st'' for Unix systems,
  371. X       ``!Prompt + !Ignore'' for AmigaDOS    systems, ``CaseIgnore''
  372. X--- 599,612 ----
  373. X  
  374. X  
  375. X  
  376. X!       Setting this flag causes character-case to be    ignored
  377. X        when attempting to match single-character argument
  378. X        names    (i.e. causes "-i" and "-I" will    be considered
  379. X        equivalent).
  380. X  
  381. X       If    the environment    variable ``PARSECNTL'' is empty    or
  382. X!      undefined,    then the parsing behavior set by the programmer
  383. X!      is    used.  If the programmer has not explicitly used
  384. X       parsecntl(3) to modify the    parsing    behavior, then the
  385. X       default behavior will be ``Flags1st'' for Unix systems,
  386. X       ``!Prompt + !Ignore'' for AmigaDOS    systems, ``CaseIgnore''
  387. X*** parseargs3.txt.OLD    Tue Mar 26 12:01:58 1991
  388. X--- parseargs3.txt    Tue Mar 26 12:00:11 1991
  389. X***************
  390. X*** 15,21 ****
  391. X       int  fparseargs(  FILE *fp,  ARGDESC *argd     )
  392. X       int  lparseargs(  ArgList *argls,    ARGDESC    *argd  )
  393. X       int  sparseargs(  char *str,  ARGDESC *argd  )
  394. X!      int  vparseargs(  ARGDESC *argd,  ...  )
  395. X       void  usage(  const ARGDESC *argd    )
  396. X  
  397. X  DESCRIPTION
  398. X--- 15,21 ----
  399. X       int  fparseargs(  FILE *fp,  ARGDESC *argd     )
  400. X       int  lparseargs(  ArgList *argls,    ARGDESC    *argd  )
  401. X       int  sparseargs(  char *str,  ARGDESC *argd  )
  402. X!      int  vparseargs(  ARGDESC *argd, int argc,     ...  )
  403. X       void  usage(  const ARGDESC *argd    )
  404. X  
  405. X  DESCRIPTION
  406. X***************
  407. X*** 39,45 ****
  408. X       ``-v\nval'' is a not).
  409. X  
  410. X       Given an ArgList and an argdesc array, lparseargs will parse
  411. X!      arguments in a file in much the same manner as parseargs.
  412. X  
  413. X       Given a single string and an argdesc array, sparseargs will
  414. X       parse arguments from a string in much the same manner as
  415. X--- 39,46 ----
  416. X       ``-v\nval'' is a not).
  417. X  
  418. X       Given an ArgList and an argdesc array, lparseargs will parse
  419. X!      arguments in an ArgList in    much the same manner as    par-
  420. X!      seargs.
  421. X  
  422. X       Given a single string and an argdesc array, sparseargs will
  423. X       parse arguments from a string in much the same manner as
  424. X***************
  425. X*** 56,62 ****
  426. X       to    parse, and a (possibly NULL terminated)    list of
  427. X       argument-strings and parses them in much the same manner as
  428. X       parseargs.     Unlike    sparseargs, vparseargs assumes that all
  429. X-      parameters    are already split up into tokens, hence    any
  430. X  
  431. X  
  432. X  
  433. X--- 57,62 ----
  434. X***************
  435. X*** 71,79 ****
  436. X  
  437. X  
  438. X  
  439. X!      whitespace    characters contained in    any of the string-
  440. X!      parameters    are used as is (and will be considered a part of
  441. X!      an    argument name or value).
  442. X  
  443. X  
  444. X       Given an argdesc array, usage will    print the usage    for the
  445. X--- 71,80 ----
  446. X  
  447. X  
  448. X  
  449. X!      parameters    are already split up into tokens, hence    any whi-
  450. X!      tespace characters    contained in any of the    string-parameters
  451. X!      are used as is (and will be considered a part of an argument
  452. X!      name or value).
  453. X  
  454. X  
  455. X       Given an argdesc array, usage will    print the usage    for the
  456. X***************
  457. X*** 103,109 ****
  458. X  
  459. X       argTypePtr_t  ad_type;
  460. X        This field is    a pointer to a type conversion function
  461. X!       (such    as the ones provided in    argtype(3). The    type
  462. X        conversion function is responsible for verifying the
  463. X        validity of the argument, allocating any necessary
  464. X        storage for its internal representation, and converting
  465. X--- 104,110 ----
  466. X  
  467. X       argTypePtr_t  ad_type;
  468. X        This field is    a pointer to a type conversion function
  469. X!       (such    as the ones provided in    argtype(3)). The type
  470. X        conversion function is responsible for verifying the
  471. X        validity of the argument, allocating any necessary
  472. X        storage for its internal representation, and converting
  473. X***************
  474. X*** 121,128 ****
  475. X  
  476. X       ARBPTR  ad_valp;
  477. X        This field is    a generic pointer to the storage used to
  478. X!       represent the    internal value of the command-line argu-
  479. X!       ment.    It may be a pointer to a number, a boolean value,
  480. X  
  481. X  
  482. X  
  483. X--- 122,128 ----
  484. X  
  485. X       ARBPTR  ad_valp;
  486. X        This field is    a generic pointer to the storage used to
  487. X!       represent the    internal value of the command-line
  488. X  
  489. X  
  490. X  
  491. X***************
  492. X*** 137,163 ****
  493. X  
  494. X  
  495. X  
  496. X!       a string, a list, or anything    else for which there
  497. X!       exists a corresponding arg-type function to use in the
  498. X!       ad_type field. In the    case of    of parseargs(1)    this
  499. X!       field    must be    the name of the    corresponding shell vari-
  500. X!       able which eventually    hold the value of the argument
  501. X!       given    on the command-line.
  502. X  
  503. X       const char     *ad_prompt;
  504. X        This field contains the long-name of the argument and
  505. X        an optional description (the description must    be
  506. X        separated from the long-name by at least one whitespace
  507. X!       characters and may optionally    be enclosed in a set of
  508. X        balanced delimiters (such as parentheses, curly-braces,
  509. X!       square-brackets, or angle-brackets. If the long-name
  510. X        contains any uppercase characters, then the substring
  511. X        of long-name consisting of all uppercase characters is
  512. X!       used as the argument name and    the entire long-name is
  513. X!       used as the name of the argument-value (if a value my
  514. X!       be supplied).    The long-name may be matched by    supplying
  515. X!       a unique prefix of either the    argument name or the
  516. X!       argument-value name.
  517. X  
  518. X  DEFINING ARGDESC ARRAYS
  519. X       When defining an argdesc array, the first item in the list
  520. X--- 137,164 ----
  521. X  
  522. X  
  523. X  
  524. X!       argument. It may be a    pointer    to a number, a boolean
  525. X!       value, a string, a list, or anything else for    which
  526. X!       there    exists a corresponding arg-type    function to use
  527. X!       in the ad_type field.    In the case of of parseargs(1)
  528. X!       this field must be the name of the corresponding shell
  529. X!       variable which will eventually hold the value    of the
  530. X!       argument given on the    command-line.
  531. X  
  532. X       const char     *ad_prompt;
  533. X        This field contains the long-name of the argument and
  534. X        an optional description (the description must    be
  535. X        separated from the long-name by at least one whitespace
  536. X!       character and    may optionally be enclosed in a    set of
  537. X        balanced delimiters (such as parentheses, curly-braces,
  538. X!       square-brackets, or angle-brackets). If the long-name
  539. X        contains any uppercase characters, then the substring
  540. X        of long-name consisting of all uppercase characters is
  541. X!       used as the argument keyword and the entire long-name
  542. X!       is used as the name of the argument (if a value my be
  543. X!       supplied). The long-name may be matched by supplying a
  544. X!       unique prefix    of either the argument keyword or the
  545. X!       argument name.
  546. X  
  547. X  DEFINING ARGDESC ARRAYS
  548. X       When defining an argdesc array, the first item in the list
  549. X***************
  550. X*** 186,197 ****
  551. X       ENDOFARGS
  552. X         };
  553. X  
  554. X-      This describes a program accepting    up to three flag argu-
  555. X-      ments and one or two positional arguments,    plus a list of
  556. X-      additional    file arguments.     Only the first    positional
  557. X  
  558. X  
  559. X  
  560. X  Page 3
  561. X  
  562. X  
  563. X--- 187,197 ----
  564. X       ENDOFARGS
  565. X         };
  566. X  
  567. X  
  568. X  
  569. X  
  570. X+ 
  571. X+ 
  572. X  Page 3
  573. X  
  574. X  
  575. X***************
  576. X*** 203,209 ****
  577. X  
  578. X  
  579. X  
  580. X!      argument is required.  The    possible flags (in UNIX) are:
  581. X  
  582. X       -c    count  An integer repetition count.  This defaults to
  583. X             two.
  584. X--- 203,212 ----
  585. X  
  586. X  
  587. X  
  588. X!      This describes a program accepting    up to three flag argu-
  589. X!      ments and one or two positional arguments,    plus a list of
  590. X!      additional    file arguments.     Only the first    positional argu-
  591. X!      ment is required.    The possible flags (in UNIX) are:
  592. X  
  593. X       -c    count  An integer repetition count.  This defaults to
  594. X             two.
  595. X***************
  596. X*** 251,263 ****
  597. X        "-x value"); Its mere    presence (or lack thereof) on the
  598. X        command-line is sufficient to    determine the necessary
  599. X        action(s) to take (as    in "-x").  Boolean argument types
  600. X!       and Pseudo-argument types automatically default to ARG-
  601. X!       NOVAL.
  602. X  
  603. X-      ARGVALOPT
  604. X  
  605. X  
  606. X- 
  607. X  Page 4
  608. X  
  609. X  
  610. X--- 254,263 ----
  611. X        "-x value"); Its mere    presence (or lack thereof) on the
  612. X        command-line is sufficient to    determine the necessary
  613. X        action(s) to take (as    in "-x").  Boolean argument types
  614. X!       and Pseudo-argument types automatically default to
  615. X  
  616. X  
  617. X  
  618. X  Page 4
  619. X  
  620. X  
  621. X***************
  622. X*** 269,274 ****
  623. X--- 269,277 ----
  624. X  
  625. X  
  626. X  
  627. X+       ARGNOVAL.
  628. X+ 
  629. X+      ARGVALOPT
  630. X        This flag is used to indicate    that the command-line
  631. X        argument takes a value (as in    "-s string" or
  632. X        "/str=string") but that the value to this command-line
  633. X***************
  634. X*** 318,326 ****
  635. X        line.
  636. X  
  637. X       ARGVALSEP
  638. X-       The value to this argument was supplied in a separate
  639. X-       argv element from the    argument itself    (as in "-x value"
  640. X-       as opposed to    "-xvalue").
  641. X  
  642. X  
  643. X  
  644. X--- 321,326 ----
  645. X***************
  646. X*** 335,340 ****
  647. X--- 335,344 ----
  648. X  
  649. X  
  650. X  
  651. X+       The value to this argument was supplied in a separate
  652. X+       argv element from the    argument itself    (as in "-x value"
  653. X+       as opposed to    "-xvalue").
  654. X+ 
  655. X       ARGKEYWORD
  656. X        This argument    was matched as a keyword (long-form) on
  657. X        the command-line and not as a    single character.
  658. X***************
  659. X*** 383,395 ****
  660. X        provided.
  661. X  
  662. X       arg_description(ad)
  663. X-       Return the description string    (or an empty string if no
  664. X-       description was given) for this argument.
  665. X  
  666. X-      ARG_isPOSITIONAL(ad)
  667. X  
  668. X  
  669. X- 
  670. X  Page 6
  671. X  
  672. X  
  673. X--- 387,395 ----
  674. X***************
  675. X*** 401,406 ****
  676. X--- 401,410 ----
  677. X  
  678. X  
  679. X  
  680. X+       Return the description string    (or an empty string if no
  681. X+       description was given) for this argument.
  682. X+ 
  683. X+      ARG_isPOSITIONAL(ad)
  684. X        Evaluates to TRUE if this argument may be positionally
  685. X        matched.
  686. X  
  687. X***************
  688. X*** 449,461 ****
  689. X       arrays. The "old-style" is    still accepted (but if used it is
  690. X       recommended that the STARTOFARGS macro is used in conjunc-
  691. X       tion with ENDOFARGS).  An example use of these macros
  692. X-      (which, with one exception, all begin with    ``CMD'') follows:
  693. X-       #include <parseargs.h>
  694. X  
  695. X-       static BOOL bflag = FALSE;
  696. X  
  697. X  
  698. X- 
  699. X  Page 7
  700. X  
  701. X  
  702. X--- 453,461 ----
  703. X***************
  704. X*** 467,472 ****
  705. X--- 467,476 ----
  706. X  
  707. X  
  708. X  
  709. X+      (which, with one exception, all begin with    ``CMD'') follows:
  710. X+       #include <parseargs.h>
  711. X+ 
  712. X+       static BOOL bflag = FALSE;
  713. X        static char *arg1 = CHARNULL;
  714. X        static char *arg2 = CHARNULL;
  715. X  
  716. X***************
  717. X*** 515,524 ****
  718. X       keywords to display command-usage for all command-line
  719. X       styles.  In Addition, for VMS style commands, the qualifiers
  720. X       /INPUT=file, /OUTPUT=file,    and /ERROR=file, may be    used to
  721. X-      redirect stdin, stdout, and stderr    (respectively) to a file.
  722. X-      For AmigaDOS style    commands, the keyword ``ENDKWDS'' may be
  723. X-      used to disable parsing for any more keywords on the
  724. X-      command-line.
  725. X  
  726. X  
  727. X  
  728. X--- 519,524 ----
  729. X***************
  730. X*** 533,538 ****
  731. X--- 533,543 ----
  732. X  
  733. X  
  734. X  
  735. X+      redirect stdin, stdout, and stderr    (respectively) to a file.
  736. X+      For AmigaDOS style    commands, the keyword ``ENDKWDS'' may be
  737. X+      used to disable parsing for any more keywords on the
  738. X+      command-line.
  739. X+ 
  740. X  SUPPLYING DEFAULT ARGUMENTS
  741. X       Programs that use parseargs may be    given default arguments
  742. X       under UNIX    and PCs    through    the use    of environment variables
  743. X***************
  744. X*** 543,549 ****
  745. X       is    parsed.     The command-line will over-ride any options that
  746. X       are specified in this environment variable    (except    that
  747. X       ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
  748. X!      from the command-line
  749. X  
  750. X       It    is important to    note that the contents of the
  751. X       ``CMD_ARGS'' environment variable are NOT expanded    by the
  752. X--- 548,554 ----
  753. X       is    parsed.     The command-line will over-ride any options that
  754. X       are specified in this environment variable    (except    that
  755. X       ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
  756. X!      from the command-line if they are selected).
  757. X  
  758. X       It    is important to    note that the contents of the
  759. X       ``CMD_ARGS'' environment variable are NOT expanded    by the
  760. X***************
  761. X*** 579,593 ****
  762. X       Prompt
  763. X        Prompt the user for any missing arguments that are
  764. X        required on the command-line.    No special escaping or
  765. X!       quoting is performed on the user input. Required argu-
  766. X!       ments    that expect a list of values will be repeatedly
  767. X!       prompted for (one item per line) until a blank line
  768. X!       (followed by a carriage return) is entered.
  769. X  
  770. X-      Ignore
  771. X  
  772. X  
  773. X- 
  774. X  Page 9
  775. X  
  776. X  
  777. X--- 584,593 ----
  778. X       Prompt
  779. X        Prompt the user for any missing arguments that are
  780. X        required on the command-line.    No special escaping or
  781. X!       quoting is performed on the user input. Required
  782. X  
  783. X  
  784. X  
  785. X  Page 9
  786. X  
  787. X  
  788. X***************
  789. X*** 599,609 ****
  790. X  
  791. X  
  792. X  
  793. X        Ignore any unrecognized or improperly    specified
  794. X        command-line arguments and continue execution    of the
  795. X        program. Normally, if    an argument is unmatched (or is
  796. X!       improperly specified), a usage message is printed pro-
  797. X!       gram execution is terminated.
  798. X  
  799. X       OptsOnly
  800. X        Under    UNIX, setting this flag    will disable the parsing
  801. X--- 599,614 ----
  802. X  
  803. X  
  804. X  
  805. X+       arguments that expect    a list of values will be repeat-
  806. X+       edly prompted    for (one item per line)    until a    blank
  807. X+       line (followed by a carriage return) is entered.
  808. X+ 
  809. X+      Ignore
  810. X        Ignore any unrecognized or improperly    specified
  811. X        command-line arguments and continue execution    of the
  812. X        program. Normally, if    an argument is unmatched (or is
  813. X!       improperly specified), a usage message is printed and
  814. X!       program execution is terminated.
  815. X  
  816. X       OptsOnly
  817. X        Under    UNIX, setting this flag    will disable the parsing
  818. X***************
  819. X*** 635,659 ****
  820. X        positional argument.
  821. X  
  822. X       CaseIgnore
  823. X!       Setting this flag cause character-case to be ignored
  824. X        when attempting to match single-character argument
  825. X        names    (i.e. causes "-i" and "-I" will    be considered
  826. X        equivalent).
  827. X  
  828. X       If    the environment    variable ``PARSECNTL'' is empty    or unde-
  829. X!      fined, then parsing behavior set by the programmer    is used.
  830. X!      If    the programmer has not explicitly used parsecntl(3) to
  831. X!      modify the    parsing    behavior, then the default behavior will
  832. X!      be    ``Flags1st'' for Unix systems, ``!Prompt + !Ignore'' for
  833. X!      AmigaDOS systems, ``CaseIgnore'' for MS-DOS and OS/2 sys-
  834. X!      tems, and ``Prompt'' for VMS systems.
  835. X  
  836. X- USAGE MESSAGES
  837. X-      Through the use of    an environment variable    (or a VMS sym-
  838. X-      bol), the user may    control    the syntax and the verbosity of
  839. X  
  840. X  
  841. X- 
  842. X  Page 10
  843. X  
  844. X  
  845. X--- 640,659 ----
  846. X        positional argument.
  847. X  
  848. X       CaseIgnore
  849. X!       Setting this flag causes character-case to be    ignored
  850. X        when attempting to match single-character argument
  851. X        names    (i.e. causes "-i" and "-I" will    be considered
  852. X        equivalent).
  853. X  
  854. X       If    the environment    variable ``PARSECNTL'' is empty    or unde-
  855. X!      fined, then the parsing behavior set by the programmer is
  856. X!      used.  If the programmer has not explicitly used par-
  857. X!      secntl(3) to modify the parsing behavior, then the    default
  858. X!      behavior will be ``Flags1st'' for Unix systems, ``!Prompt +
  859. X!      !Ignore'' for AmigaDOS systems, ``CaseIgnore'' for    MS-DOS
  860. X  
  861. X  
  862. X  
  863. X  Page 10
  864. X  
  865. X  
  866. X***************
  867. X*** 665,670 ****
  868. X--- 665,675 ----
  869. X  
  870. X  
  871. X  
  872. X+      and OS/2 systems, and ``Prompt'' for VMS systems.
  873. X+ 
  874. X+ USAGE MESSAGES
  875. X+      Through the use of    an environment variable    (or a VMS sym-
  876. X+      bol), the user may    control    the syntax and the verbosity of
  877. X       the command-usage messages    that are printed by parseargs.
  878. X       The desired level of verbosity may    be set by defining the
  879. X       environment variable ``USAGECNTL" to be a combination of
  880. X***************
  881. X*** 712,725 ****
  882. X       LongOpts
  883. X        Long-option syntax is    displayed.
  884. X  
  885. X-      KeyWords
  886. X-       Same as LongOpts.
  887. X  
  888. X  
  889. X  
  890. X- 
  891. X- 
  892. X- 
  893. X  Page 11
  894. X  
  895. X  
  896. X--- 717,725 ----
  897. X***************
  898. X*** 731,736 ****
  899. X--- 731,739 ----
  900. X  
  901. X  
  902. X  
  903. X+      KeyWords
  904. X+       Same as LongOpts.
  905. X+ 
  906. X       If    the environment    variable ``USAGECNTL'' is empty    or unde-
  907. X       fined, then the default usage level (which    is presently
  908. X       ``Verbose + Options'') will be used.
  909. X***************
  910. X*** 751,765 ****
  911. X       ArgList structure.    L_NEXT returns the address of the next
  912. X       item in the list and L_STRING returns the string-value of
  913. X       the current list-item.  L_FLAGS return the    arg-flags for a
  914. X!      given item    in the list. With non-multivalued, only    the flags
  915. X!      in    the argument descriptor    are needed; lists and vectors
  916. X!      however need a set    of flags for each item they contain. Once
  917. X!      an    arg-list has been created, it may be deallocated using
  918. X!      the function listFree. ListFree takes two parameters, the
  919. X!      first of which is the address of the first    item in    the arg-
  920. X!      list, and the second of which is a    boolean    value that is
  921. X!      TRUE only if each value pointed to    by each    item should also
  922. X!      be    deallocated.
  923. X  
  924. X       An    alternative to argument-lists is argument vectors (or
  925. X       arg-vectors).  Arg-vectors    use the    ARGVEC flag instead of
  926. X--- 754,766 ----
  927. X       ArgList structure.    L_NEXT returns the address of the next
  928. X       item in the list and L_STRING returns the string-value of
  929. X       the current list-item.  L_FLAGS return the    arg-flags for a
  930. X!      given item    in the list. With non-multivalued arguments, only
  931. X!      the flags in the argument descriptor are needed; lists and
  932. X!      vectors however need a set    of flags for each item they con-
  933. X!      tain. Once    an arg-list has    been created, it may be    deallo-
  934. X!      cated using the function listFree.    ListFree takes one param-
  935. X!      eter: first of which is the address of the    first item in the
  936. X!      arg-list.
  937. X  
  938. X       An    alternative to argument-lists is argument vectors (or
  939. X       arg-vectors).  Arg-vectors    use the    ARGVEC flag instead of
  940. X***************
  941. X*** 782,788 ****
  942. X  
  943. X        ( StrVec.array[ StrVec.count ] == (char *)NULL )
  944. X  
  945. X-      is    always true, and character-vectors will    always have an
  946. X  
  947. X  
  948. X  
  949. X--- 783,788 ----
  950. X***************
  951. X*** 797,802 ****
  952. X--- 797,803 ----
  953. X  
  954. X  
  955. X  
  956. X+      is    always true, and character-vectors will    always have an
  957. X       extra NUL-character at the    end such that:
  958. X  
  959. X        ( CharVec.array[ CharVec.count ] == '\0' )
  960. X***************
  961. X*** 848,854 ****
  962. X          printf(    "String[%d]=%s,    flags=%x\n",
  963. X              i, StrVec.array[i], StrVec.flags[i] );
  964. X  
  965. X-          for ( i = 0 ; i < NumVec.count ; i++ )
  966. X  
  967. X  
  968. X  
  969. X--- 849,854 ----
  970. X***************
  971. X*** 863,868 ****
  972. X--- 863,869 ----
  973. X  
  974. X  
  975. X  
  976. X+          for ( i = 0 ; i < NumVec.count ; i++ )
  977. X          printf(    "Number[%d]=%s,    flags=%x\n",
  978. X              i, NumVec.array[i], NumVec.flags[i] );
  979. X  
  980. X***************
  981. X*** 887,900 ****
  982. X       being converted.  Its main    use is to find the location in
  983. X       which to store the    converted value, located in
  984. X       argd->ad_valp.  The string    value to be converted is passed
  985. X!      in    argp (which will be NULL if the    ARGNOVAL flag was set for
  986. X       the corresponding entry in    the arg-descriptor table).  The
  987. X!      copyf flag    is TRUE    if the argp string value must be copied
  988. X       when saved.  Most non-string types    are copied implicitly
  989. X       (for example, integer arguments are stored    in binary form,
  990. X       so    the original string value need not be saved), so this
  991. X       argument can usually be ignored.  Put simply, this    flag is
  992. X!      TRUE when argp points to a    temporary buffer area.
  993. X  
  994. X       If    the type function successfully converts    the value, and
  995. X       uses the entire value, it should return TRUE.  If the type
  996. X--- 888,901 ----
  997. X       being converted.  Its main    use is to find the location in
  998. X       which to store the    converted value, located in
  999. X       argd->ad_valp.  The string    value to be converted is passed
  1000. X!      in    vp (which will be NULL if the ARGNOVAL flag was    set for
  1001. X       the corresponding entry in    the arg-descriptor table).  The
  1002. X!      copyf flag    is TRUE    if the vp string value must be copied
  1003. X       when saved.  Most non-string types    are copied implicitly
  1004. X       (for example, integer arguments are stored    in binary form,
  1005. X       so    the original string value need not be saved), so this
  1006. X       argument can usually be ignored.  Put simply, this    flag is
  1007. X!      TRUE when vp points to a temporary    buffer area.
  1008. X  
  1009. X       If    the type function successfully converts    the value, and
  1010. X       uses the entire value, it should return TRUE.  If the type
  1011. X***************
  1012. X*** 914,920 ****
  1013. X        #define REALLOC(ptr,size)  ((! ptr) ?    malloc(size) : realloc(ptr, size))
  1014. X        typedef ARGVEC_T(FILE    *)  FILEvec_t;
  1015. X  
  1016. X-       BOOL    argReadFile(  ARGDESC *ad,  char *vp,  BOOL copyf  )
  1017. X  
  1018. X  
  1019. X  
  1020. X--- 915,920 ----
  1021. X***************
  1022. X*** 929,934 ****
  1023. X--- 929,935 ----
  1024. X  
  1025. X  
  1026. X  
  1027. X+       BOOL    argReadFile(  ARGDESC *ad,  char *vp,  BOOL copyf  )
  1028. X        {
  1029. X             register    FILE *fp;
  1030. X             fp = fopen(vp, "r");
  1031. X***************
  1032. X*** 979,986 ****
  1033. X  
  1034. X       Under VAX/VMS and AmigaDOS, single-character options are not
  1035. X       used and the ``long'' name    (in the    prompt field of    an argu-
  1036. X!      ment descriptor) is always    used to    match for possible argu-
  1037. X!      ments (or keywords, or qualifiers).
  1038. X  
  1039. X  
  1040. X  
  1041. X--- 980,986 ----
  1042. X  
  1043. X       Under VAX/VMS and AmigaDOS, single-character options are not
  1044. X       used and the ``long'' name    (in the    prompt field of    an argu-
  1045. X!      ment descriptor) is always    used to    match for possible
  1046. X  
  1047. X  
  1048. X  
  1049. X***************
  1050. X*** 995,1000 ****
  1051. X--- 995,1002 ----
  1052. X  
  1053. X  
  1054. X  
  1055. X+      arguments (or keywords, or    qualifiers).
  1056. X+ 
  1057. X       For all supported operating systems, a long option    may be
  1058. X       matched in    one of two ways: it may    match all uppercase char-
  1059. X       acters in the prompt field, or it may match all characters
  1060. X***************
  1061. X*** 1045,1052 ****
  1062. X       pe_NOMATCH
  1063. X        Unable to match the named argument. This occurs when
  1064. X        the argument keyword name passed to parsecntl    (using
  1065. X-       the pc_ARGFLAGS functions code) was found in the given
  1066. X-       argdesc-array    or in its default-list.
  1067. X  
  1068. X  
  1069. X  
  1070. X--- 1047,1052 ----
  1071. X***************
  1072. X*** 1061,1066 ****
  1073. X--- 1061,1069 ----
  1074. X  
  1075. X  
  1076. X  
  1077. X+       the pc_ARGFLAGS functions code) was found in the given
  1078. X+       argdesc-array    or in its default-list.
  1079. X+ 
  1080. X       pe_BADMODE
  1081. X        Bad mode for given command in    parsecntl. This    occurs
  1082. X        when pc_WRITE    or pc_RDWR mode    is passed to parsecntl in
  1083. X***************
  1084. X*** 1110,1121 ****
  1085. X       Hence multiple ``leading dash'' arguments may specified as
  1086. X       follows:
  1087. X  
  1088. X-       -f-dash_arg1 -f-dash_arg2  ...
  1089. X  
  1090. X  
  1091. X  
  1092. X- 
  1093. X- 
  1094. X  Page 17
  1095. X  
  1096. X  
  1097. X--- 1113,1121 ----
  1098. X***************
  1099. X*** 1127,1139 ****
  1100. X  
  1101. X  
  1102. X  
  1103. X  BUGS
  1104. X       When a non-multivalued argument appears more than once on
  1105. X       the command-line then only    the last value supplied    is used.
  1106. X       A problem occurs however in the following scenario: suppose
  1107. X!      `-s' is an    option that takes an optional string argument (nd
  1108. X!      suppose `-x' is some boolean flag). Then if the following
  1109. X!      command-line is issued:
  1110. X  
  1111. X        command  -s string  -x  -s
  1112. X  
  1113. X--- 1127,1141 ----
  1114. X  
  1115. X  
  1116. X  
  1117. X+       -f-dash_arg1 -f-dash_arg2  ...
  1118. X+ 
  1119. X  BUGS
  1120. X       When a non-multivalued argument appears more than once on
  1121. X       the command-line then only    the last value supplied    is used.
  1122. X       A problem occurs however in the following scenario: suppose
  1123. X!      `-s' is an    option that takes an optional string argument
  1124. X!      (and suppose `-x' is some boolean flag). Then if the follow-
  1125. X!      ing command-line is issued:
  1126. X  
  1127. X        command  -s string  -x  -s
  1128. X  
  1129. X***************
  1130. X*** 1159,1166 ****
  1131. X       argument flags ARGPOS, ARGVALOPT, ARGVALREQ, ARGVALGIVEN,
  1132. X       ARGNOVAL, and ARGVEC; and VAX/VMS version and IBM-PC version
  1133. X       by    Brad Appleton
  1134. X- 
  1135. X- 
  1136. X  
  1137. X  
  1138. X  
  1139. X--- 1161,1166 ----
  1140. XNo differences encountered
  1141. END_OF_FILE
  1142. if test 36746 -ne `wc -c <'PATCH'`; then
  1143.     echo shar: \"'PATCH'\" unpacked with wrong size!
  1144. fi
  1145. # end of 'PATCH'
  1146. fi
  1147. echo shar: End of shell archive.
  1148. exit 0
  1149.  
  1150. exit 0 # Just in case...
  1151. -- 
  1152. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1153. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1154. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1155. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1156.